﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xts
{
    namespace XInterBank
    {
        namespace Strategy
        {
            public class InterBankTradingAgent
            {
                #region data members
                private string x_user;
                private string x_password;
                private bool x_IsInit;
                private bool x_IsIndentified;

                private IceRuntime.XIceApp x_icApp;                
                private Ice.Logger x_logger;

                private MarketData.IXQuoteDetailDataMonitorI x_quoteDetailDataMonitor;
                private MarketData.IXSnapshotDataMonitorI x_snapshotDataMonitor;
                private TradingClient.IXOrderNortifyerI x_orderNotifyer;

                private MarketData.IXQuoteDetailDataHandler x_quoteDetailDataHandler;
                private MarketData.IXSnapshotDataHandler x_snapshotDataHandler;
                private TradingClient.IXOrderNortifyerHandler x_orderNotifyerHandler;
                private TradingClient.IXAmiOrderDeliveryCBHandler x_amiOrderDeliveryCBHandler;
                private TradingClient.IXAmiTradingQueryCBHandler x_amiTradingQueryCBHandler;

                protected AuthorityClient.XLoginServerAgent_sync x_loginServerAgent;
                protected AuthorityClient.XSessionAgent_sync x_sessionAgent;
                protected TradingClient.XOrderDeliveryAgent_async x_orderDeliveryAgent;
                protected TradingClient.XTradingQueryAgent_async x_tradingQueryAgent;
                
                public string User { get { return x_user; } }
                public bool IsInit { get { return x_IsInit; } }
                public bool IsIndentified { get { return x_IsIndentified; } }
                #endregion
                public bool Initialize()
                {
                    try
                    {
                        Ice.Properties tradingAgentProperties = Ice.Util.createProperties();
                        tradingAgentProperties.load("interbank_tradingagent.xcfg");

                        x_icApp = new IceRuntime.XIceApp(tradingAgentProperties.getProperty("IceApp"));
                        x_logger = x_icApp.RetrieveLogger();
                        if(!x_icApp.InitObjectAdapter(tradingAgentProperties.getProperty("Ice.Adapter.Name"), tradingAgentProperties.getProperty("Ice.Adapter.Endpoint")))
                        {
                            x_logger.error("Creating ObjectAdapter error.");
                            return false;
                        }



                        return true;
                    }
                    catch(Ice.Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    return false;
                }

                public bool Login(string user, string password)
                {
                    return false;
                }

                public bool Logout()
                {
                    return false;
                }

                public bool SubscribeSymbol(string[] symbolIdLst)
                {
                    return false;
                }

                public bool SendOrder(XSendingOrder sendingOrder)
                {
                    return false;
                }

                public bool SendMarketMakingOrder(XSendingMarketMakingOrder sendingOrder)
                {
                    return false;
                }

                public bool CancelOrder(XCancelOrderReq cancelReq)
                {
                    return false;
                }

                public bool BatchCancelOrder(XCancelOrderReq cancelReqLst)
                {
                    return false;
                }

                public bool QueryOrderInfo(string orderId, string customOrderId)
                {
                    return false;
                }

                public bool BatchQueryOrderInfo(string accountId)
                {
                    return false;
                }

                public bool QueryOrderFill(string orderId, string customOrderId)
                {
                    return false;
                }

                public bool BatchQueryOrderFill(string accountId)
                {
                    return false;
                }
            }
        }
        
    }
    
}
